Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove mouse enter/leave polyfill and add native event #10247

Closed
wants to merge 3 commits into from

Conversation

jquense
Copy link
Contributor

@jquense jquense commented Jul 21, 2017

🔥 rel: #9824

I’m starting with this, and getting the tests to pass. I’m a bit unsure if there is more needed for the Portal case, but I believe the existing tests for that pass right now.

I wasn’t sure if complicating SimpleEventPlugin made sense, or if maybe it’s worth splitting that into two: PhasedEventPlugin and DirectEventPlugin or something.

@@ -64,6 +64,8 @@ var topLevelTypes = {
topLoadedMetadata: 'loadedmetadata',
topLoadStart: 'loadstart',
topMouseDown: 'mousedown',
topMouseEnter: 'mouseenter',
topMouseLeave: 'mouseleave',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this file still exist? It seems to be mostly (only?) used as a type import, but has actual code in it. Does this make it into a build? maybe worth changing to a purely flow file so there isn't any worry of runtime usage?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dependency === 'topMouseEnter' ||
dependency === 'topMouseLeave'
) {
if (isEventSupported('mouseenter', true)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're assuming all supported browsers will support mouseenter events, do we need the isEventSupported check?

};
} else {
type.registrationName = onEvent;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the type object polymorphic which could hurt performance a bit. We may want to define these fields on type with null values to avoid creating multiple hidden classes.

@aweary
Copy link
Contributor

aweary commented Jul 21, 2017

This is great! I love seeing all that red 😄

I wasn’t sure if complicating SimpleEventPlugin made sense, or if maybe it’s worth splitting that into two: PhasedEventPlugin and DirectEventPlugin or something.

I think two plugins might be cleaner, but I'm not sure it's justified if DirectEventPlugin would just be handling mouseenter/mouseleave.

@jquense
Copy link
Contributor Author

jquense commented Jul 21, 2017

I think two plugins might be cleaner, but I'm not sure it's justified if DirectEventPlugin would just be handling mouseenter/mouseleave.

Yeah i'm not sure how many other events might fit there, perhaps native focusIn and focusOut once FF supporting it is old enough

@aweary
Copy link
Contributor

aweary commented Jul 21, 2017

I think inlining the logic in SimpleEventPlugin is fine for now, and we can revisit when we have a stronger case for DirectEventPlugin.

@jquense
Copy link
Contributor Author

jquense commented Jul 24, 2017

I can't get jests watch mode to work with the new project setup... npm test works but watch mode just throws

TypeError: Cannot read property '' of undefined

      at ModuleMap._getModuleMetadata (node_modules/jest-haste-map/build/module_map.js:84:30)

making it tough to debug the CI failure

@jquense jquense force-pushed the mouse-enter-leave-2 branch from 2a69ba1 to b92e54c Compare July 24, 2017 16:04
@jquense
Copy link
Contributor Author

jquense commented Jul 24, 2017

OK I added a portal fixture, and its broken.

I'm guessing what we have to do is prevent a dispatch if the relatedTarget is a portal of the current target. That is easy enough to do in an EventPlugin, however the case where you leave the portal, ultimately the portal at the same time is a bit harder, be cause you need to find any ancestors listening for ML, calculate if they are being left as well and trigger them at that point.

@sebmarkbage do you have thoughts on where start with something like this? I'd be concerned that we will end up writing a full polyfill anway way to get that behavior. Perhaps though it could be pushed to the propagators? I think that would require they have knowledge of the paired events in the ME case.

@sebmarkbage
Copy link
Collaborator

We'll probably need to decide pretty quickly if we want to revert the behavior in the 16 cycle. One way to make that decision could be to make an attempt at a polyfill using the dispatch mechanism to show that it would be prohibitively big.

@sebmarkbage
Copy link
Collaborator

Maybe it's ok to treat this as if the user just moved out and quickly back in again?

@jquense
Copy link
Contributor Author

jquense commented Jul 24, 2017

Is this the only pair of events like this? e.g. non-bubbling events that "own" an entire subtree? The only other use-case for this behavior I can think of is something like "focusenter" and "focusleave" but those aren't real events (though there has been some talk of implementing something like it, b/c its useful). I ask because the Portal bubbling is really helpful for lots of other cases. If this is the only hard case, i'd say it's better to have this inconsistency vs reverting the behavior entirely.

I'll take shot at implementing it here to see what would be required tho

@vivaldoy
Copy link

vivaldoy commented Jul 25, 2017 via email

@gaearon
Copy link
Collaborator

gaearon commented Jan 5, 2018

Closing the PR as stale, we can track this in #11972.

@gaearon gaearon closed this Jan 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants